     var repeat;
     var totalslide;
     var countslide;
     var s_time;
     var status = 0; //0 :play 1:pause 2:next 3:prev
     var d_time;
     $.fn.slide = function(params) {
         repeat = params.repeat;
         totalslide = params.totalslide;
         countslide = totalslide;
         s_time = 0;

         //init first item
         div_first = $('#' + params.firstId);
         d_time = div_first.attr('data');
         div_first.addClass('active').fadeIn();
         if (div_first.find('video').get(0)) {
             div_first.find('video').get(0).play();
         }
         counter = setInterval(slideInterval, 1000);

         function slideInterval() {
             if (status == 0) {
                 s_time++;
                 if (s_time == d_time) {
                     countslide--;
                     if (countslide == 0 && repeat == 0) {
                         clearInterval(counter);
                     } else {
                         div_active = $('.active');
                        hidetemplate(div_active);
                         if (countslide == 0 && repeat == 1) {
                             div_next = div_first;
                             countslide = totalslide;
                         } else {
                             div_next = div_active.next();
                         }

                         showtemplate(div_next);

                     }
                 }
             }
         }
     };

     function hidetemplate(div_active) {
         if (div_active.find('video').get(0)) {
             div_active.find('video').get(0).pause();
             div_active.find('video').get(0).currentTime = 0;
         }
         div_active.removeClass('active').fadeOut();
     }

     function showtemplate(div_next) {
         div_next.addClass('active').fadeIn();
         if (div_next.find('video').get(0)) {
             div_next.find('video').get(0).play();
         }
          d_time = div_next.attr('data');
           s_time = 0;
     }

     function setStatus(code) {
         switch (code) {
             case 0:
                 div_active = $('.active');
                 if (div_active.find('video').get(0)) {
                     div_active.find('video').get(0).play();
                 }
                 status = code;
                 break;
             case 1:
                 div_active = $('.active');
                 if (div_active.find('video').get(0)) {
                     div_active.find('video').get(0).pause();
                 }
                 status = code;
                 break;
             case 2:
                if(countslide>1){
                 countslide--;
                 div_active = $('.active');
                 hidetemplate(div_active);
                 div_next = div_active.next();
                 showtemplate(div_next);
                 if(status==1 && div_next.find('video').get(0)){
                     div_next.find('video').get(0).pause();
                 }
             }
                 break;
             case 3:
                  if(countslide < totalslide){
                  countslide++;
                 div_active = $('.active');
                 hidetemplate(div_active);

                 div_next = div_active.prev();
                 showtemplate(div_next);
                 if(status==1 && div_next.find('video').get(0)){
                     div_next.find('video').get(0).pause();
                 }
             }
                 break;
         }
     }